Pain is a multidimensional experience that includes sensory and affective components. Human imaging studies have identified patterns of activities within key cortical areas that can encode different pain experiences, but it remains unclear how pain can also be encoded reliably at the level of individual neurons or populations of neurons. The primary somatosensory cortex (S1) has been thought to be important in the sensory-discriminative aspect of the pain, yet the anterior cingulate cortex (ACC) is known to play a crucial role in the affective-motivational experience of pain. However, imaging studies cannot provide causal relationship between circuits and behavior and are further limited by poor temporal resolution. Therefore, a complete understanding of neural codes for acute pain in physiology remains missing. Neuromodulation is a potential option for pain treatment; but current techniques such as deep brain stimulation (DBS) lack optimal targets and require constant stimulation with undesired side effects. We will use a rat model to uncover pain mechanisms of key central neural circuits and develop a demand-based brain-machine interface (BMI) that integrates timely detection of the pain signal and precise temporal analgesic control. In Aim 1, we will identify cortical circuitry for encoding acute pain. We will collect simultaneous S1 and ACC ensemble recordings from freely behaving rats and characterize their firing patterns at both single cell and population levels. In Aim 2, we will determine how the central pain circuitry is altered by central vs. peripheral analgesic strategy using optogenetic and pharmacological approaches. In Aim 3, we will develop reliable computational strategies to decode acute pain based on neural ensemble recordings from the central pain circuits involving S1 and ACC. In Aim 4, we will develop a real-time closed-loop BMI system for modulating acute pain by combining a detection arm of neural decoding with a therapeutic arm of central neurostimulation. We will test its effectiveness using established pain behavior assays. Together, these results will enable us to dissect neural circuits and mechanisms for acute pain and provide a template for next-generation demand-based pain treatment. RELEVANCE (See Instructions): This project is aimed to dissect circuit mechanisms of acute pain and develop closed-loop BMI system for pain control. We will combine experimental, computational and engineering techniques to decode acute pain signals and apply them to develop real-time BMI system for pain modulation using neurostimulation. The proposed research will not only reveal important mechanisms of acute pain, but will also provide new insiahts on theraoeutic treatment of oain analaesia.